<?php

use yii\helpers\Html;
use yii\grid\GridView;

$this->title = '客户列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="customer-index">

    <div class="box">
        <div class="box-header">
          <?= Html::a(Yii::t('app', 'Create Customer'), ['create'], ['class' => 'btn btn-success']) ?>
        </div>
        <div class="box-body">
        <p>
             <?php echo $this->render('_search', ['model' => $searchModel]); ?>
        </p>

        <?= GridView::widget([
                'dataProvider' => $dataProvider,
                'layout'  =>  "{items}\n{summary}\n{pager}",
                'columns' => [
                    ['class' => 'yii\grid\SerialColumn'],

                    [
                        'attribute' => 'name',
                        'value' => function ($model) {
                                return $model->name;
                            },
                    ],

                    [
                      'attribute' => 'user_id',
                      'value' => function($model){
                            return isset($model->user) ? $model->user->name : '管理员';
                      }
                    ],


                    [
                        'class' => 'yii\grid\ActionColumn',
                        'header' => '操 作',
                        'template' =>"{view} {update}"
                    ],
                ],
            ]); ?>

    </div>
    </div>
        
</div>
